package config

import "gitee.com/llakcs/gnetty/commom"

type ClientConf struct {
	BufferSize      int                          //缓冲区大小
	ChanSize        int                          //队列大小
	ChanReadHandler commom.ChannelInboundHandler //业务处理器
	DecoderHandler  commom.DecodeHandler         //自定义解码处理
	EncodeHandler   commom.EncodeHandler         //自定义编码器
	Addr            string
}

func ClientConfBuild() *ClientConf {
	return &ClientConf{
		BufferSize:      0,
		ChanSize:        0,
		ChanReadHandler: nil,
		DecoderHandler:  nil,
		EncodeHandler:   nil,
	}
}

//设置ip地址
func (c *ClientConf) WithIpAddr(addr string) *ClientConf {
	c.Addr = addr
	return c
}

//设置接收缓冲区大小
func (c *ClientConf) WithBufferSize(bufsize int) *ClientConf {
	c.BufferSize = bufsize
	return c
}

//设置通道队列大小
func (c *ClientConf) WithChanSize(chansize int) *ClientConf {
	c.ChanSize = chansize
	return c
}

//设置业务处理器
func (c *ClientConf) WithChanReadHandler(ch commom.ChannelInboundHandler) *ClientConf {
	c.ChanReadHandler = ch
	return c
}

//设置解码处理器
func (c *ClientConf) WithDecodeHandler(d commom.DecodeHandler) *ClientConf {
	c.DecoderHandler = d
	return c
}

//设置编码处理器
func (c *ClientConf) WithEncodeHandler(e commom.EncodeHandler) *ClientConf {
	c.EncodeHandler = e
	return c
}
